{*******************************************************************************
* The contents of this file are used with permission, subject to the Mozilla   *
* Public License Version 1.1 (the "License"); you may not use this file except *
* in compliance with the License. You may obtain a copy of the License at      *
* http://www.mozilla.org/MPL/                                                  *
*                                                                              *
* Software distributed under the License is distributed on an "AS IS" basis,   *
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for *
* the specific language governing rights and limitations under the License.    *
*                                                                              *
* The Original Code is distributed as part of the "mediate" product and is     *
* Copyright (C) @home media limited. All Rights Reserved.                      *
*                                                                              *
* Email: support@athomemedia.co.uk                                             *
* Web:   http://www.athomemedia.co.uk                                          *
*******************************************************************************}

unit Empty;

interface

uses AVRenderer, AHMTypes, Colour;

type
  TAHMEmptyRenderer = class(TAHMAVRenderer)
  private
    FRaisedEmptyPlaylist: Boolean;
  protected
  public
    procedure Render(Rect: TAHMRectF; Shade: TAHMCanvasShade; Gamma: TAHMCanvasColour;
                     XScale, YScale: Single; XFlip, YFlip: Boolean); override;
  end;

implementation

uses ApplicationManager, Actions;

procedure TAHMEmptyRenderer.Render(Rect: TAHMRectF; Shade: TAHMCanvasShade;
                                   Gamma: TAHMCanvasColour; XScale, YScale: Single;
                                   XFlip, YFlip: Boolean);
begin
  inherited;

  // If rendering windowed then just clear our error raised flag and exit
  if not FFullScreen then
  begin
    FRaisedEmptyPlaylist := False;
    Exit;
  end;

  // Rendering fullscreen - raise "onempty" playlist action event, but only once
  if not FRaisedEmptyPlaylist then
  begin
    // Ensure there are no other outstanding actions first
   with ApplicationManagerInstance.ActionManager do
      if not ActionsOutstanding then ProcessAction(AC_ONEMPTY);
    FRaisedEmptyPlaylist := True;
  end;
end;


end.
